﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.ComponentModel;
using System.Web.UI.HtmlControls;

namespace Axe.Web.Controls
{
    [DefaultProperty("Source")]
    [ToolboxData("<{0}:IFrameControl runat=server></{0}:IFrameControl>")]
    public class IFrameControl : Control
    {
        #region public string Source
        [UrlProperty, Bindable(true, BindingDirection.TwoWay), Themeable(false), Localizable(false)]
        public string Source
        {
            get
            {
                object o = ViewState["Source"];

                if (o != null && o is string)
                    return (string)o;

                return String.Empty;
            }
            set
            {
                ViewState["Source"] = value;
            }
        } 
        #endregion

        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteBeginTag("iframe");
            writer.WriteAttribute("src", Source);
            writer.WriteEndTag("iframe");
        }
    }
}
